package org.jeecg.modules.simulator.factory;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.parameter.api.entity.SimLine;
import org.jeecg.modules.parameter.biz.mapper.SimLineMapper;
import org.jeecg.modules.simulator.line.LineLoader;
import org.jeecg.modules.simulator.model.line.Line;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: simulator-b20240918
 * @description:
 * @author: renzhg
 * @create: 2024-10-14 17:09
 **/
@Slf4j
@Primary
@Service
public class SimLineService implements LineLoader {
    @Resource
    private SimLineMapper mapper;

    @Getter
    Map<String, Line> lineMap = new HashMap<>();

    @Override
    public void loadData() {
        List<SimLine> allLine = mapper.getAllLine();
        for (SimLine simline : allLine) {
            Line line = new Line();
            line.setLineId(simline.getLineId());
            line.setLineName(simline.getLineName());
            line.setOperationStatus(simline.getOperationStatus());
            lineMap.put(simline.getLineId(), line);
        }
    }


}
